const defaultState = {
  cityName: ""
}

export default (state = defaultState,action) => {
  // react-redux 
  // 深拷贝一份 state
  const newState=JSON.parse(JSON.stringify(state));
  switch (action.type) {
    case "setCityName":// 初始化
      newState.cityName=action.value;
      return newState
      break;
    case "changeCityName": // 修改城市
      newState.cityName=action.value;
      return newState
      break;
    default:
      break;
  }
  return state;
}